// SASS variables for normal drag handle and bar size.
// Override in your scss file by setting these variables FIRST, then including this file.
@drag-handle-width: 10px;
@drag-handle-height: 10px;
@drag-bar-size: 6px;

// Query to kick us into "mobile" mode with larger drag handles/bars.
// See: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer
@mobile-media-query: "(pointer: coarse)";

// Mobile handle/bar sizes.  Override as above.
@drag-handle-mobile-width: 34px;
@drag-handle-mobile-height: 34px;

// Handle color/border.
@drag-handle-background-colour: rgba(0, 0, 0, 0.2);
@drag-handle-border: 1px solid rgba(255, 255, 255, 0.7);

.ReactCrop {
  position: relative;
  display: inline-block;
  cursor: crosshair;
  overflow: hidden;
  max-width: 100%;
  background-color: #000;

  &:focus {
    outline: none;
  }

  &--disabled,
  &--locked {
    cursor: inherit;
  }

  &__image {
    display: block;
    max-width: 100%;
    touch-action: manipulation;
  }

  &--crop-invisible &__image {
    opacity: 0.5;
  }

  &__crop-selection {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate3d(0, 0, 0);
    box-sizing: border-box;
    cursor: move;
    box-shadow: 0 0 0 9999em rgba(0, 0, 0, 0.5);
    touch-action: manipulation;

    .ReactCrop--disabled & {
      cursor: inherit;
    }

    .ReactCrop--circular-crop & {
      border-radius: 50%;
      box-shadow: 0px 0px 1px 1px white, 0 0 0 9999em rgba(0, 0, 0, 0.5);
    }

    border: 1px solid;
    border-image-source: url("");
    border-image-slice: 1;
    border-image-repeat: repeat;
  }

  &__rule-of-thirds-vt::before,
  &__rule-of-thirds-vt::after,
  &__rule-of-thirds-hz::before,
  &__rule-of-thirds-hz::after {
    content: "";
    display: block;
    position: absolute;
    background-color: rgba(255, 255, 255, 0.4);
  }

  &__rule-of-thirds-vt {

    &::before,
    &::after {
      width: 1px;
      top: 0;
      bottom: 0;
    }

    &::before {
      left: 33.3333%;
      left: calc(100% / 3);
    }

    &::after {
      left: 66.6666%;
      left: calc(100% / 3 * 2);
    }
  }

  &__rule-of-thirds-hz {

    &::before,
    &::after {
      left: 0;
      right: 0;
      height: 1px;
    }

    &::before {
      top: 33.3333%;
      top: calc(100% / 3);
    }

    &::after {
      top: 66.6666%;
      top: calc(100% / 3 * 2);
    }
  }

  &__drag-handle {
    position: absolute;
    width: @drag-handle-width;
    height: @drag-handle-height;
    background-color: @drag-handle-background-colour;
    border: @drag-handle-border;
    box-sizing: border-box;

    // This stops the borders disappearing when keyboard
    // nudging.
    outline: 1px solid transparent;
  }

  .ord-nw {
    top: 0;
    left: 0;
    margin-top: -(ceil(@drag-handle-height / 2));
    margin-left: -(ceil(@drag-handle-width / 2));
    cursor: nw-resize;
  }

  .ord-n {
    top: 0;
    left: 50%;
    margin-top: -(ceil(@drag-handle-height / 2));
    margin-left: -(ceil(@drag-handle-width / 2));
    cursor: n-resize;
  }

  .ord-ne {
    top: 0;
    right: 0;
    margin-top: -(ceil(@drag-handle-height / 2));
    margin-right: -(ceil(@drag-handle-width / 2));
    cursor: ne-resize;
  }

  .ord-e {
    top: 50%;
    right: 0;
    margin-top: -(ceil(@drag-handle-height / 2));
    margin-right: -(ceil(@drag-handle-width / 2));
    cursor: e-resize;
  }

  .ord-se {
    bottom: 0;
    right: 0;
    margin-bottom: -(ceil(@drag-handle-height / 2));
    margin-right: -(ceil(@drag-handle-width / 2));
    cursor: se-resize;
  }

  .ord-s {
    bottom: 0;
    left: 50%;
    margin-bottom: -(ceil(@drag-handle-height / 2));
    margin-left: -(ceil(@drag-handle-width / 2));
    cursor: s-resize;
  }

  .ord-sw {
    bottom: 0;
    left: 0;
    margin-bottom: -(ceil(@drag-handle-height / 2));
    margin-left: -(ceil(@drag-handle-width / 2));
    cursor: sw-resize;
  }

  .ord-w {
    top: 50%;
    left: 0;
    margin-top: -(ceil(@drag-handle-height / 2));
    margin-left: -(ceil(@drag-handle-width / 2));
    cursor: w-resize;
  }

  // Use the same specificity as the ords above but just
  // come after.
  &__disabled &__drag-handle {
    cursor: inherit;
  }

  &__drag-bar {
    position: absolute;

    &.ord-n {
      top: 0;
      left: 0;
      width: 100%;
      height: @drag-bar-size;
      margin-top: -(@drag-bar-size / 2);
    }

    &.ord-e {
      right: 0;
      top: 0;
      width: @drag-bar-size;
      height: 100%;
      margin-right: -(@drag-bar-size / 2);
    }

    &.ord-s {
      bottom: 0;
      left: 0;
      width: 100%;
      height: @drag-bar-size;
      margin-bottom: -(@drag-bar-size / 2);
    }

    &.ord-w {
      top: 0;
      left: 0;
      width: @drag-bar-size;
      height: 100%;
      margin-left: -(@drag-bar-size / 2);
    }
  }

  &--new-crop &__drag-bar,
  &--new-crop &__drag-handle,
  &--fixed-aspect &__drag-bar {
    display: none;
  }

  &--fixed-aspect &__drag-handle.ord-n,
  &--fixed-aspect &__drag-handle.ord-e,
  &--fixed-aspect &__drag-handle.ord-s,
  &--fixed-aspect &__drag-handle.ord-w {
    display: none;
  }

  @media (pointer: coarse) {
    &__drag-handle {
      width: @drag-handle-mobile-width;
      height: @drag-handle-mobile-height;
    }

    &__drag-bar {
      display: none;
    }

    .ord-nw,
    .ord-n,
    .ord-ne,
    .ord-e,
    .ord-s,
    .ord-sw,
    .ord-w {
      display: none;
    }

    .ord-se {
      margin-bottom: -1px;
      margin-right: -1px;
    }
  }
}